<?php

declare(strict_types=1);
namespace Service\StorageService;


use Service\BaseService;
use Service\Code\Normal;
use App\Model\BbcModel\PdaSearchHistory;

class StockSearchHistoryService extends BaseService
{
    public function addSearchHistory($cid,$mn_sid,$manager_id,$content) {
        return PdaSearchHistory::instance()->add(['cid'=>$cid,'mn_sid'=>$mn_sid,'manager_id'=>$manager_id,'content'=>$content,'cd'=>time()]);
    }
    
    public function delSearchHistory($manager_id) {
        $response=PdaSearchHistory::instance()->edit(['manager_id'=>$manager_id,'df'=>0], ['df'=>1,'md'=>time()]);
        if($response){
            return Normal::returnCode(Normal::SUC, '成功');
        }
        return Normal::returnCode(Normal::FAIL, '失败');
    }
    
    public function getList($manager_id) {
        $list= PdaSearchHistory::instance()->listPages(['manager_id'=>$manager_id,'df'=>0,'_order_'=>['id'=>'desc']], 10, 1);
        return Normal::returnCode(Normal::SUC, '成功', $list??[]);
    }
    
}
